#!/usr/bin/python3

list1 = ["小明","小美","晓晓","小红"]
print(list1.index("小明"))
print(list1[1])#根据下标打印值

list_2 =[10,20,60,80]
def score(list_2):
    sum = 0
    for i in list_2:
        sum += i
    return sum


result = score(list_2)
print(f'求和:{result}')


# 累加求和
def get_sum(num):
        sum = 0
        for i in range(num):
            sum += i
        return sum
num1 =get_sum(101)
print(num1)

# 平均数
num3 = [1,3,2]
def average(num3):
        sum = 0
        for i in num3:
            sum += i
        return sum/len(num3)

c = average(num3)
print(c)
score = [1,2,4,78,46,34]
print(dir(score))
score.sort()
print(f'升序:{score}')
score.pop()   #默认删除最后一个元素
print(score)
# 列表函数最大值
def get_max(n1):
    max_i = -1
    for i in n1:
        if i >= max_i:
            max_i = i
    return max_i
n1 = [1,5,10,18,2,34,71,53,94,79,37,96,30]
result = get_max(n1)
print(f'最大值：{result}')
def get_max(lst):
    """
    返回列表lst的最大值
    :param lst:
    :return:
    """
    if not lst:
        return None
    max_value = lst[0]
    for item in lst:
        if item > max_value:
            max_value = item

    return max_value


lst = [4, 2, 1, 6, 7, 9]
max_value = get_max(lst)
print(max_value)
# 定义一个函数 out_even，接收一个参数 max_num,
# 将 0 ~ max_num 内所有的偶数找出来，放到一个列表里，并返回
# 例如：out_even(10)，得到[0, 2, 4, 6, 8, 10]
new_list = []
def out_even(max_num):
    for i in range(max_num):
        if i % 2 == 0:
            new_list.append(i)
    return new_list

result = out_even(6)

print(result)


